import QtQuick 1.0
import "Article.js" as ArticleUtil
import "CommomUtil.js" as CommonUtil
Rectangle {
  id:focus_image_item
  width: 480
  height: 60


  Image{
      id:focusImageItem

      source:imgUrl


      fillMode: Image.PreserveAspectFit
      smooth: true
      MouseArea {
          anchors.fill: parent
          onClicked: {
              console.log("focusImage articleId："+articleId)
              forwardToContent(articleId)
          }
      }
  }

  function forwardToContent(articleId){
      console.log("forwardToContent:"+articleId);
      ArticleUtil.setArticleId(articleId); //文章点击 查看详细，设置文章id

      var pageNum="";
      var doc = new XMLHttpRequest();
      doc.onreadystatechange = function() {
          if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
          } else if (doc.readyState == XMLHttpRequest.DONE) {
              var a = doc.responseXML.documentElement;
              console.log("nodeName:"+a.childNodes[1].childNodes[1].nodeName);

              pageNum =a.childNodes[1].childNodes[1].childNodes[0].nodeValue;

              console.log(pageNum);

              ArticleUtil.setPageNum(pageNum);//

               mainPage.pageStack.push(Qt.resolvedUrl("ArticleContent.qml"));
          }
      }

      doc.open("GET", ArticleUtil.getContentUrl(articleId));
      doc.send();
      console.log("aricle page num:"+pageNum);

  }
}
